package com.boom.springapp.demoapplication.controller;

import com.boom.springapp.mystarterautoconfigure.service.HelloService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hhl
 * @version 1.0
 * @description
 * @date 2025/8/24 22:56
 */

@RestController
public class TestController {

    private final HelloService helloService;

    public TestController(HelloService helloService) {
        this.helloService = helloService;
    }

    @GetMapping("/hello")
    public String hello(@RequestParam(required = false) String name) {
        if (name != null && !name.isEmpty()) {
            return helloService.sayHello(name);
        }
        return helloService.sayHello();
    }

    @GetMapping("/config")
    public String getConfig() {
        return "Prefix: " + helloService.getProperties().getPrefix() +
                ", DefaultName: " + helloService.getProperties().getDefaultName();
    }
}